package com.asiainfo.service;
/*
 * 
 * 课程操作service
 */
import java.util.Date;
import com.asiainfo.bean.Course;
import com.asiainfo.dao.Course_Dao;

public class CourseService {
	//添加课程
	public void addCourse(String[] args){
		if(args.length != 2){
			System.out.println("对不起，请输入合法参数");
			return;
		}
		Course course = new Course(args[1],(int)new Date().getTime());
		Course_Dao cd = new Course_Dao();
		Course findcourse = cd.findcourseByName(course.getCourse_name());
		if(findcourse!=null){
			System.out.println("该课程已存在");
		}else{
			int result = cd.addcourse(course);
			if(result>0){
				System.out.println("课程【"+course.getCourse_name()+"】添加成功");
			}else{
				System.out.println("课程添加失败");
			}
		}
	}
	//根据名称查找课程
	public Course findCourseByName(String courseName){
		Course_Dao cd = new Course_Dao();
		return cd.findcourseByName(courseName);
	}
	//根据ID查找课程
	public Course findCourseById(int id){
		Course_Dao cd = new Course_Dao();
		return cd.findcourseById(id);
	}
}
